import 'package:flutter/material.dart';
import 'package:app/generated/app_strings.dart';
import 'package:app/src/http/bean/wroks/contract_bean.dart';
import 'package:app/src/http/bean/ywx_limit.dart';
import 'package:app/src/ui/app_ui.dart';

import '../../../../../http/bean/worksdo/equipment_management_bean.dart';
import '../../../../../http/bean/worksdo/material_requisition_bean.dart';
import '../../../../../manager/ywx_manager.dart';

///公用列表内容
class ContentList2 {
  static Widget ywxItem(
      BuildContext context, YwxItem? item, EquipmentInfo data) {
    if (item?.ReviewType == ReviewType.TicketCenter) {
      //工单中心
      return _TicketCenter(context, item, data);
    }
    return _TicketCenter(context, item, data);
  }

  //last true 不带‘/’ fals 带‘/’ 即：是否为最后一个字符
  static Widget _text(String name, String? value, {bool last = false}) {
    var str = name + ":$value";
    List<InlineSpan>? children = null;
    if (!last) {
      children = [
        TextSpan(text: '/', style: AppStyle.textStyleWithEntryGrey()),
      ];
    }
    return Text.rich(TextSpan(
        style: AppStyle.textStyleWithEntry(), text: str, children: children));
    return Text(
      str,
      style: AppStyle.textStyleWithEntry(),
    );
  }

  //自动换行
  static Widget _wrap(List<Widget> children) {
    return Padding(
        padding: EdgeInsets.symmetric(vertical: 8),
        child: Wrap(
          alignment: WrapAlignment.start,
          children: children,
        ));
  }

  //工单中心
  static Widget _TicketCenter(
      BuildContext context, YwxItem? item, EquipmentInfo data) {
    // //工单号
    // Widget MaterialName = _text(AppStrings.of(context).TicketNo, data.RepairNo);
    //等级
    Widget MaterialCode =
    _text(AppStrings.of(context).Lv, data.getUrgencyLevelName(context));
    //一级设备名称
    Widget Brand = _text(AppStrings.of(context).DName1, data.EquipmentName1);
    //二级设备名称
    Widget Specifications =
    _text(AppStrings.of(context).DName2, data.EquipmentName2);
    //三级设备名称
    Widget InventoryNum =
    _text(AppStrings.of(context).DName3, data.EquipmentName3);
    //工单类型
    Widget RepairType = _text(
        AppStrings.of(context).Workordertype, data.getRepairTypeName(context));
    //报修时间；要显示到时分秒
    Widget InventoryArea =
    _text(AppStrings.of(context).Repairtime, data.AddTime);
    //报修人员
    Widget repairman =
    _text(AppStrings.of(context).repairman, data.AddPersonName);
    //工序
    Widget process =
    _text(AppStrings.of(context).process, data.ProcessName, last: true);
    return _wrap([
      // MaterialName,
      MaterialCode,
      Brand,
      Specifications,
      InventoryNum,
      RepairType,
      InventoryArea,
      repairman,
      process
    ]);
  }
}
